package com.feeyin.radar.crm.controller;

import com.feeyin.radar.crm.service.ScheduleManageService;
import com.feeyin.radar.sys.service.RecordRangeService;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

public class ScheduleManageController extends MultiActionController
{
  private ScheduleManageService scheduleManageService;
  private RecordRangeService recordRangeService;
  private String scheduleManage;
  private String weekSchedule;
  private String monthSchedule;

  public ScheduleManageService getScheduleManageService()
  {
    return this.scheduleManageService;
  }

  public void setScheduleManageService(ScheduleManageService scheduleManageService) {
    this.scheduleManageService = scheduleManageService;
  }

  public RecordRangeService getRecordRangeService() {
    return this.recordRangeService;
  }

  public void setRecordRangeService(RecordRangeService recordRangeService) {
    this.recordRangeService = recordRangeService;
  }

  public String getScheduleManage() {
    return this.scheduleManage;
  }

  public void setScheduleManage(String scheduleManage) {
    this.scheduleManage = scheduleManage;
  }

  public String getWeekSchedule() {
    return this.weekSchedule;
  }

  public void setWeekSchedule(String weekSchedule) {
    this.weekSchedule = weekSchedule;
  }

  public String getMonthSchedule() {
    return this.monthSchedule;
  }

  public void setMonthSchedule(String monthSchedule) {
    this.monthSchedule = monthSchedule;
  }

  public ModelAndView display(HttpServletRequest request, HttpServletResponse response)
  {
    Map map = new HashMap();
    String isViewDept = (String)request.getSession().getAttribute("isViewDeptSchedule");
    Integer userId = (Integer)request.getSession().getAttribute("userId");

    if (userId != null) {
      map.put("scheduleForm", this.scheduleManageService.getTodaySchedules(userId, isViewDept));
    }
    map.put("contactWays", this.recordRangeService.getActivityRecordRangesByDictionaryCode("34"));
    return new ModelAndView(getScheduleManage(), map);
  }

  public ModelAndView weekSchedule(HttpServletRequest request, HttpServletResponse response)
  {
    Map map = new HashMap();
    String isViewDept = (String)request.getSession().getAttribute("isViewDeptSchedule");
    Integer userId = (Integer)request.getSession().getAttribute("userId");

    if (userId != null) {
      map.put("weekSchedules", this.scheduleManageService.getWeekSchedules(userId, isViewDept));
    }
    map.put("contactWays", this.recordRangeService.getActivityRecordRangesByDictionaryCode("34"));
    return new ModelAndView(getWeekSchedule(), map);
  }

  public ModelAndView monthSchedule(HttpServletRequest request, HttpServletResponse response)
  {
    Map map = new HashMap();
    String isViewDept = (String)request.getSession().getAttribute("isViewDeptSchedule");
    Integer userId = (Integer)request.getSession().getAttribute("userId");

    if (userId != null) {
      map.put("monthSchedules", this.scheduleManageService.getMonthSchedules(userId, isViewDept));
    }
    map.put("contactWays", this.recordRangeService.getActivityRecordRangesByDictionaryCode("34"));
    return new ModelAndView(getMonthSchedule(), map);
  }
}